import request from "../../../utils/request";
import nRequest from "../../../utils/normalRequert";
import user from "../../../store/modules/user";

export function getCheckRackInfo(data) {
    return request({
        url: '/app/rackUtil/getCheckRackInfo',
        method: 'get',
    })
}

export function checkRack(data) {
    return request({
        url: '/app/rackUtil/checkRack',
        method: 'post',
        data: data
    })
}

export function backRack(data) {
    return request({
        url: '/app/rackUtil/backRack',
        method: 'post',
        data: data
    })
}

export function existTask(rackCode, invCode) {
    return request({
        url: '/app/rackUtil/existTask?invCode=' + invCode + '&rackCode=' + rackCode,
        method: 'get',
    })
}

const ckBaseUrl = "http://192.168.90.40:8081";

export function analysisQRCode(qrCode) {
    return nRequest({
        method:  'post',
        url: ckBaseUrl + '/api/RackCall/AnalysisQRCode',
        data: {
            "qrCodeDto": qrCode
        },
        header: {
            'Content-Type': 'application/json'
        }
    })
}

export function addTask(form) {
    return nRequest({
        method:  'post',
        url: ckBaseUrl + '/api/RackCall/Call',
        data: {
            "ID": form.rackCode,
            "OPType": "101",
            "ServerNo": "",
            "Status": "0",
            "account": user.state.name,
            "data": form.data
        },
        header: {
            'Content-Type': 'application/json'
        }
    })
}

export function cancelTask(rackCode) {
    return nRequest({
        method:  'post',
        url: ckBaseUrl + '/api/RackCall/Call',
        data: {
            "ID": rackCode,
            "OPType": "105",
            "Status": "0",
            "account": user.state.name,
        },
        header: {
            'Content-Type': 'application/json'
        }
    })
}
export function getRackErrorInfo() {
    return nRequest({
        method:  'post',
        url: ckBaseUrl + '/api/RackCall/Call',
        data: {
            "OPType": "109",
            "Status": "0"
        },
        header: {
            'Content-Type': 'application/json'
        }
    })
}

export function dealErrorStock(locId) {
    return nRequest({
        method:  'post',
        url: ckBaseUrl + '/api/RackCall/Call',
        data: {
            "ID": locId,
            "OPType": "110",
            "Status": "0"
        },
        header: {
            'Content-Type': 'application/json'
        }
    })
}
